filter: &ops::CompileFilter,
prev: &CrateListingV1,
force: bool) -> CargoResult<BTreeMap<String, Option<PackageId>>> {
- if let CompileFilter::Everything { .. } = *filter {
+ if !filter.is_specific() {
// If explicit --bin or --example flags were passed then those'll
// get checked during cargo_compile, we only care about the "build
// everything" case here
use std::path::Path;
-use ops::{self, CompileFilter, Packages};
+use ops::{self, Packages};
use util::{self, human, CargoResult, ProcessError};
use core::Workspace;
};
let mut bins = pkg.manifest().targets().iter().filter(|a| {
- !a.is_lib() && !a.is_custom_build() && match options.filter {
- CompileFilter::Everything { .. } => a.is_bin(),
- CompileFilter::Only { .. } => options.filter.matches(a),
+ !a.is_lib() && !a.is_custom_build() && if !options.filter.is_specific() {
+ a.is_bin()
+ } else {
+ options.filter.matches(a)
}
});
if bins.next().is_none() {
- match options.filter {
- CompileFilter::Everything { .. } => {
- bail!("a bin target must be available for `cargo run`")
- }
- CompileFilter::Only { .. } => {
- // this will be verified in cargo_compile
- }
+ if !options.filter.is_specific() {
+ bail!("a bin target must be available for `cargo run`")
+ } else {
+ // this will be verified in cargo_compile
}
}
if bins.next().is_some() {
- match options.filter {
- CompileFilter::Everything { .. } => {
- bail!("`cargo run` requires that a project only have one \
- executable; use the `--bin` option to specify which one \
- to run")
- }
- CompileFilter::Only { .. } => {
- bail!("`cargo run` can run at most one executable, but \
- multiple were specified")
- }
+ if !options.filter.is_specific() {
+ bail!("`cargo run` requires that a project only have one \
+ executable; use the `--bin` option to specify which one \
+ to run")
+ } else {
+ bail!("`cargo run` can run at most one executable, but \
+ multiple were specified")
}
}
return Ok(None)
}
let (test, mut errors) = if options.only_doc {
+ assert!(options.compile_opts.filter.is_specific());
run_doc_tests(options, test_args, &compilation)?
} else {
run_unit_tests(options, test_args, &compilation)?
// If a specific test was requested or we're not running any tests at all,
// don't run any doc tests.
- if let ops::CompileFilter::Only { .. } = options.compile_opts.filter {
+ if options.compile_opts.filter.is_specific() {
match errors.len() {
0 => return Ok(None),
_ => return Ok(Some(CargoTestError::new(test, errors)))